package com.nantong.admin.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nantong.admin.domain.SalesOrder;
import com.nantong.admin.domain.model.response.salesorder.SalesOrderVo;
import com.nantong.common.mybatis.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 销售订单Mapper接口
 */
@Mapper
public interface SalesOrderMapper extends BaseMapperPlus<SalesOrder, SalesOrderVo> {


    /**
     * 查询销售订单列表（使用关联查询）
     */
    default List<SalesOrderVo> selectSalesOrderList(Wrapper<SalesOrder> wrapper){
        return selectVoList(wrapper);
    }

    /**
     * 分页查询销售订单列表
     */
    default Page<SalesOrderVo> selectPageList(Page<SalesOrder> build, Wrapper<SalesOrder> wrapper){
        return selectVoPage(build, wrapper);
    }


    /**
     * 查询销售订单详情（包含销售人员姓名和客户名称）
     */
    SalesOrderVo selectSalesOrderDetail(@Param("salesOrderId") Long salesOrderId);

    /**
     * 销售统计总体数据
     */
    com.nantong.admin.domain.model.response.salesorder.SalesStatisticsVo selectSalesStatisticsSummary(
            @Param("beginTime") java.util.Date beginTime,
            @Param("endTime") java.util.Date endTime,
            @Param("salespersonId") Long salespersonId);

    /**
     * 销售统计时间序列数据
     */
    java.util.List<com.nantong.admin.domain.model.response.salesorder.SalesStatisticsVo.TimeSeriesData> selectSalesStatisticsTimeSeries(
            @Param("beginTime") java.util.Date beginTime,
            @Param("endTime") java.util.Date endTime,
            @Param("salespersonId") Long salespersonId,
            @Param("statisticsType") String statisticsType);

    /**
     * 销售统计销售人员数据
     */
    java.util.List<com.nantong.admin.domain.model.response.salesorder.SalesStatisticsVo.SalespersonData> selectSalesStatisticsBySalesperson(
            @Param("beginTime") java.util.Date beginTime,
            @Param("endTime") java.util.Date endTime,
            @Param("salespersonId") Long salespersonId);

}

